<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3_数据类型</title>
</head>
<body>
<script>
    //JS数据类型 = 原始类型 + 引用类型
    //原始类型：number string boolean undefined未定义型 null
    //typeof:用来推断数据类型
    var a = 1;
    var b = 3.14;
    console.log(a,typeof a,b,typeof b);
    var c ='你好';
    var d ="你好~";
    console.log(c,typeof c ,d,typeof d);
    var e = true;
    var f = false;
    console.log(e,typeof e,f,typeof f);
    var g;
    console.log(g,typeof g);//声明变量但未赋值就会得到undefined未定义型

    //引用类型 Object Array Function Number Boolean...
    let obj = {
        name:'张三',
        age:18
    };
    console.log(obj,typeof obj);
    console.log(obj.name);//张三
    console.log(obj.age)
    obj.age = 19;
    console.log(obj.age);
    obj.like='吃火锅';
    console.log(obj.like);
    obj.play;
    console.log(obj.play); //undefined 访问对象不存在的属性也会得到undefiend！

    let arr = ['周一',3,5.8,true];
    console.log(arr);
    console.log(arr[0]);
    console.log(arr[1]);
    console.log(arr[2]);
    console.log(arr[3]);
    console.log(arr[33]);//访问数组不存在的下标也会得到undefined

    //Boolean()将参数转为布尔类型
    //0 undefined null NaN '' 这5个特殊值转为布尔都是false,其余情况都是true！
    console.log(Boolean(0));
    console.log(Boolean(undefined));
    console.log(Boolean(null));
    console.log(Boolean(NaN));
    console.log(Boolean(''));

    console.log(Boolean(' '));
    console.log(Boolean(1));
    console.log(Boolean('你好'));
</script>

</body>
</html>